package jspwiki.plugins;

import java.util.Map;

import com.ecyrd.jspwiki.WikiContext;
import com.ecyrd.jspwiki.plugin.PluginException;
import com.ecyrd.jspwiki.plugin.WikiPlugin;
import com.ecyrd.jspwiki.ui.TemplateManager;

/**
 * @author Francis Novilla
 */
public class HeaderResource implements WikiPlugin {

  public static final String PARAM_RESOURCE = "resource";

  /**
   * {@inheritDoc}
   */
  @SuppressWarnings("unchecked")
  public String execute(WikiContext context, Map params) throws PluginException {

    StringBuffer res = new StringBuffer();

    String resource = (String) params.get(PARAM_RESOURCE);

    String type = resource.endsWith("js") ? TemplateManager.RESOURCE_SCRIPT : TemplateManager.RESOURCE_STYLESHEET;
    TemplateManager.addResourceRequest(context, type, resource);

    return "";
  }
}
